package com.cskaoyan.dbutils;

import com.cskaoyan.connectionpool.dbcp.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.ColumnListHandler;
import org.apache.commons.dbutils.handlers.ScalarHandler;

import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.List;

/**
 * 创建日期: 2022/07/28 17:28
 *
 * @author ciggar
 *
 * BeanListHandler
 *
 */
public class QueryDemo7 {

    public static void main(String[] args) throws SQLException {

        // 创建一个QueryRunner
        QueryRunner queryRunner = new QueryRunner(DruidUtils.getDataSource());

        Long nums = queryRunner.query("select count(*) from city", new ScalarHandler<>());

        System.out.println(nums);

    }
}
